package hot100;

import comment.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: wzp
 * @CreateTime: 2024-09-12  11:17
 * @Description: 二叉树中序遍历
 * @Version: 1.0
 */
public class hot_94 {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> result=new ArrayList<>();
        if(root==null){
            return result;
        }
        dfs(root,result);
        return result;

    }
    private void dfs(TreeNode treeNode,List<Integer> result){
        if(treeNode==null){
            return;
        }
        dfs(treeNode.left,result);
        result.add(treeNode.val);
        dfs(treeNode.right,result);
    }
}
